package com.iotproject.studyservice.controller;


import com.iotproject.commonutils.R;
import com.iotproject.studyservice.entity.StudyListeningType;
import com.iotproject.studyservice.service.StudyListeningTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 听力类别 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2023-04-07
 */
@RestController
@RequestMapping("/studyservice/study-listening-type")
public class StudyListeningTypeController {

    @Autowired
    StudyListeningTypeService studyListeningTypeService;

    @PostMapping("/insertStudyListeningType")
    public R insertStudyListeningType() {
        StudyListeningType studyListeningType1 = new StudyListeningType();
        studyListeningType1.setName("四级英语");
        studyListeningType1.setCover("https://upload-up.qtfm.cn/user/ffaea5ef6cddcf5844c722a54f6eee28/1597927162_0001-151582953.png");
        studyListeningTypeService.save(studyListeningType1);
        StudyListeningType studyListeningType2 = new StudyListeningType();
        studyListeningType2.setName("六级英语");
        studyListeningType2.setCover("https://upload-up.qtfm.cn/user/ffaea5ef6cddcf5844c722a54f6eee28/1597927162_0001-151582953.png");
        studyListeningTypeService.save(studyListeningType2);
        StudyListeningType studyListeningType3 = new StudyListeningType();
        studyListeningType3.setName("每日听力");
        studyListeningType3.setCover("https://upload-up.qtfm.cn/user/ffaea5ef6cddcf5844c722a54f6eee28/1597927162_0001-151582953.png");
        studyListeningTypeService.save(studyListeningType3);
        return R.ok();
    }

    @GetMapping("getStudyListeningTypeList")
    public R getStudyListeningTypeList() {
        List<StudyListeningType> list = studyListeningTypeService.list(null);
        return R.ok().data("list", list);
    }

}

